using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace WIAssistant
{
    [ValueConversion(typeof(double), typeof(String))]
    public class WorkItemConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,System.Globalization.CultureInfo culture)
        {
            int workItemID = (int) value;
            string partToGet = (string) parameter;

            WorkItem workItem = MainMediator.Instance.GetWorkItemByID(workItemID);

            switch (partToGet)
            {
                case "Title":
                    return workItem.Title;
                case "Type":
                    return workItem.Type.Name;
                default:
                    return workItem.Id;
            }
            
            
        }
        public object ConvertBack(object value, Type targetType,object parameter,System.Globalization.CultureInfo culture)
        {
            throw new Exception("The method or operation is not implemented.");
        }

    }
}
